## HADOOP_HOME *must* be set correctly in the environment
## NOTE: this messes with the config directory for real
HADOOP_VERSION=0.17.2.1
FILES=Jesus.java JesusMapper.java JesusReducer.java DBFSReducer.java DBFSMapper.java FinalMapper.java FinalReducer.java XmlInputFormat.java
LOCAL_OUT=output
LOCAL_IN=input
REMOTE_OUT=/user/ivoysey/output
REMOTE_IN=/user/gkesden/enwiki-pages-articles
MAX_ITS=18

default: jar

jar: clean 
	mkdir jesus_classes
	javac -classpath ${HADOOP_HOME}/hadoop-$(HADOOP_VERSION)-core.jar -d jesus_classes -Xlint $(FILES)
	jar -cvf jesus.jar -C jesus_classes/ .
	rm -rf jesus_classes/

local: jar jesus.jar local.xml $(LOCAL_IN)
	rm -f ${HADOOP_HOME}/conf/hadoop-site.xml
	cp local.xml ${HADOOP_HOME}/conf/hadoop-site.xml
	rm -rf $(LOCAL_OUT)
	${HADOOP_HOME}bin/hadoop jar jesus.jar Jesus $(LOCAL_IN) $(LOCAL_OUT)

google: jar jesus.jar google.xml
	rm -f ${HADOOP_HOME}/conf/hadoop-site.xml
	cp google.xml ${HADOOP_HOME}/conf/hadoop-site.xml
	${HADOOP_HOME}bin/hadoop jar jesus.jar Jesus $(REMOTE_IN) $(REMOTE_OUT) $(MAX_ITS)

regtest: prototypes/RegTest.java
	javac prototypes/RegTest.java
	java prototypes/RegTest $(LOCAL_IN)* 

pi:
	rm -f ${HADOOP_HOME}/conf/hadoop-site.xml
	cp google.xml ${HADOOP_HOME}/conf/hadoop-site.xml
	${HADOOP_HOME}bin/hadoop jar ${HADOOP_HOME}hadoop-${HADOOP_VERSION}-examples.jar pi 50 10000000000

issh:
	ssh -D 6789 -L 50128:127.0.0.1:50128 ivoysey@64.88.164.202

rssh:
	ssh -D 6789 -L 50128:127.0.0.1:50128 rhofler@64.88.164.202

clean:
	rm -rf jesus_classes/ jesus.jar *~ output/ prototypes/RegTest.class javadoc

javadoc:
	rm -rf javadoc
	mkdir javadoc
	javadoc -classpath ${HADOOP_HOME}/hadoop-$(HADOOP_VERSION)-core.jar -private -d javadoc $(FILES)
